import request from '../http/request'
import type { ApiResponse, Question, QuestionTypesResponse } from '../http/types'

export interface GenerateQuestionsParams {
  subject: 'number-line' | 'fraction' | 'geometry' | 'function'
  difficulty: 'easy' | 'medium' | 'hard'
  count?: number
}

export interface CalculateParams {
  expression: string
  variables?: Record<string, number>
}

export const questionsApi = {
  // 生成练习题
  generateQuestions: (params: GenerateQuestionsParams): Promise<ApiResponse<Question[]>> => {
    return request.post('/questions/generate', params)
  },

  // 数学计算
  calculate: (params: CalculateParams): Promise<ApiResponse<{ result: number }>> => {
    return request.post('/calculate', params)
  },

  // 获取题目类型列表
  getQuestionTypes: (): Promise<QuestionTypesResponse> => {
    return request.get('/questions/types')
  },
}
